<%= render 'base' %>

<div class="subnav">
  <nav class="subnav-links">
    <a href="<%= admin_docs_path %>" class="subnav-item"><%= t("admin.All") %></a>
  </nav>
  <div class="subnav-search float-left">
    <form action="" method="GET">
      <input type="search" name="q" class="form-control subnav-search-input" value="<%= params[:q] %>">
      <%= icon_tag "search", class: "subnav-search-icon" %>
    </form>
  </div>
</div>

<div class="admin-admin_docs">
  <table class="table table-striped">
    <tr class="head">
      <td>Id</td>
      <td><%= t("activerecord.attributes.doc.title") %></td>
      <td><%= t("created_at") %></td>
      <td class="opts"></td>
    </tr>
    <% @docs.each do |item| %>
    <tr class="<%= cycle("","even") %> <%= "deleted" if item.deleted? %>">
      <td><%= item.id %></td>
      <td>
        <div><%= link_to item.title, admin_doc_path(item.id) %></div>
        <div class="mt-1 text-gray"><%= item.slug %></div>
        <div class="mt-1">
          <% if item.repository&.user %>
            <%= link_to item.repository&.user&.name, admin_user_path(item.repository&.user_id), class: "link-gray-dark" %> /
          <% end %>
          <% if item.repository %>
            <%= link_to item.repository&.name, admin_docs_path(repository_id: item.repository_id), class: "link-gray-dark" %>
          <% end %>
        </div>
      </td>

      <td class="text-gray" style="widith: 150px"><%= l(item.created_at) %></td>
      <td class="opts">
        <%= link_to icon_tag("pencil"), edit_admin_doc_path(item.id) %>
        <%= link_to icon_tag("trash"), admin_doc_path(item.id), method: :delete, 'data-confirm' => t("admin.Are you sure delete this item?") %>
        <!-- PRO-begin -->
        <% feature_for(:soft_delete) do %>
          <% if item.deleted? %>
            <%= link_to icon_tag("restore"), restore_admin_doc_path(item.id), method: :post, 'data-confirm' => t("admin.Are you sure restore this item?") %>
          <% end %>
        <% end %>
        <!-- PRO-end -->
      </td>
    </tr>
    <% end %>
  </table>
  <%= paginate @docs %>
</div>
